package com.lluohao.common;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by Everthing-- on 2017/7/5.
 */
public class HttpUtil {
    public static String get(String url) throws IOException{
        URL realUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
        conn.connect();
        int code = conn.getResponseCode();
        if(code>=200&&code<300){
            InputStream in = conn.getInputStream();
            return StringUtils.readFromInputStream(in, "utf-8");
        }
        return null;
    }
    public static void main(String[] args) throws  IOException{
        System.out.println(get("http://api.qingyunke.com/api.php?key=free&appid=0&msg=你好"));
    }
}
